package kt_test.room.dao

import androidx.room.*
import kt_test.room.entity.OxygenSampleEntity

@Dao
interface OxygenSampleDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertSamples(samples: List<OxygenSampleEntity>)

    // 🔥 这里是你新增的查询，必须加 @Query
    @Query("""
        SELECT * FROM oxygen_sample
        WHERE (:uid IS NULL OR userId = :uid)
        AND (:start IS NULL OR time >= :start)
        AND (:end IS NULL OR time <= :end)
        ORDER BY time ASC
    """)
    suspend fun querySamples(uid: String?, start: String?, end: String?): List<OxygenSampleEntity>
}
